<?php
var_dump($_GET);
$task_id=$_GET['task_id'] ?? '';
$dsn = "sqlsrv:Server=localhost;Database=Task";
$db = new PDO($dsn, "sa", "123456");

$sql="select *from Task where TaskId='{$task_id}'";
//var_dump($sql);
$result = $db->query($sql);
$taskInfo = $result->fetch(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>任务详情</title>
    <link rel="stylesheet" type="text/css" href="css/main.css" />
    <script>
        function firm() {
            //利用对话框返回的值 （true 或者 false）
            if (confirm("你确定提交吗？")) {
                alert("点击了确定");
                return true;
            }
            else {
                alert("点击了取消");
                return false;
            }

        }
    </script>
</head>
<body>
<div id="container">
    <a href="task_list.php">返回任务列表</a>
    <form action="update_save.php" method="post">
        <table class="update">
            <caption>
                <h3>任务详情</h3>
            </caption>
            <tr>
                <td>任务id</td>
                <td>
                    <input type="text" readonly="readonly" value="<?php echo $taskInfo['TaskId']?>" name="task_id">
                </td>
            </tr>
            <tr>
                <td>任务名称：</td>
                <td><input type="text" value="<?php echo $taskInfo['TaskName']?>" name="task_name" /></td>
            </tr>
            <tr>
                <td>任务状态：</td>
                <td><input type="text" value="<?php
                    if ($taskInfo['TaskStatus']==1){
                        echo  "新创建";
                    }elseif ($taskInfo['TaskStatus']==2){
                        echo "标记中";
                    }elseif ($taskInfo['TaskStatus']==3){
                        echo "完成";
                    }
                    ?>" readonly="readonly" style="border: none"></td>
            </tr>
            <tr>
                <td>任务内容：</td>
                <td><textarea cols="60" rows="15" name="task_content"><?php echo $taskInfo['TaskContent'];?></textarea>
                </td>
            </tr>
            <tr>
                <td></td>
                <td><a href="now.php?Task_id=<?php echo $taskInfo['TaskId']?>" onclick=" return firm()">标记为进行中</a></td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="submit" value="提交" class="btn" />
                    <input type="reset" value="重置" class="btn" />
                </td>
            </tr>
        </table>
    </form>
</div>
</body>
</html>

